import Vue from 'vue'
import Vuex from 'vuex'
import cart from './modules/cart'
import CreatePersistedState from "vuex-persistedstate"
Vue.use(Vuex)

export default new Vuex.Store({
  plugins: [
    CreatePersistedState({
      key: 'ugo-cart',
      paths: ['cart'],
      storage: {
        getItem: key => uni.getStorageSync(key),
        setItem: (key, value) => uni.setStorageSync(key, value),
        removeItem: key => uni.removeStorageSync(key)
      }
    })
  ],
  modules: {
    cart
  }
})